import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { UnifiedViteWeappTailwindcssPlugin as uvwt } from "weapp-tailwindcss/vite";
const { WeappTailwindcssDisabled } = require('./shared')
import { plugins as postcssPlugins } from './postcss.config.cjs'
const path = require('path')
// vite 插件配置
const vitePlugins = [uni(), uvwt({
  rem2rpx: true,
  disabled: WeappTailwindcssDisabled
})];

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
	alias: {
		/**
		 * 解释 ： 
		 * __dirname : 当前文件所在的目录的绝对路径
		 * "../src/assets" : 表示相对于 __dirname ,要进行拼接的目录
		 * path.resolve() : 将上面两个目录拼接起来
		 * 
		 * "@assets" : 给拼接的目录起一个别名，在项目中可以通过别名的方式进行资源的引入
		 */
		"@assets" : path.resolve(__dirname,"./assets"),
		"@components" : path.resolve(__dirname,"./components"),
		'@api': path.resolve(__dirname,"./http/api"),
		'@': path.resolve(__dirname,"./")
	}
  },
  plugins: vitePlugins,
  // 假如 postcss.config.js 不起作用，请使用内联 postcss Latset
  css: {
    postcss: {
      plugins: postcssPlugins,
    },
  },
});
